package com.fita.entity.order.reverse.aviation;

import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Embeddable;
import javax.persistence.Transient;
import java.util.Date;

/**
 * @description:
 * @author: 11200
 * @date: 2019/8/21
 */
@Embeddable
public class AviationBook {

    /**
     * 航空公司
     */
    private String bookAirline;

    /**
     * 航班号
     */
    private String flightNumber;

    /**
     * 舱位
     */
    private String position;

    /**
     * 出发时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date departureTime;

    /**
     * 到达时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date arriveTime;

    /**
     * 出发地
     */
    private String departureLocation;

    /**
     * 到达地
     */
    private String arriveLocation;

    /**
     * 飞行时间
     */
    private String flightTime;

    /**
     *  +1 或 -1 天
     */
    private String crossDay;


    /**
     * 返程航班号
     */
    private String returnFlightNumber;

    /**
     * 返程舱位
     */
    private String returnPosition;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date returnDepartureTime;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date returnArriveTime;

    private String returnDepartureLocation;

    private String returnArriveLocation;

    /**
     * 飞行时间
     */
    private String returnFlightTime;

    /**
     *  +1 或 -1 天
     */
    private String returnCrossDay;

    public AviationBook() {
    }


    /**
     * 是否有效
     * @return
     */
    @Transient
    public boolean isValid(){
        if (this.departureTime == null || this.arriveTime == null){
            return false;
        }
        return StringUtils.isNoneBlank(this.bookAirline, this.flightNumber, this.position, this.departureLocation, this.arriveLocation, this.flightTime, this.crossDay);
    }

    /**
     * 有返回航班吗？
     * @return
     */
    public boolean hasReturnFlight(){

        return StringUtils.isNotBlank(this.returnFlightNumber);
    }

    public String getBookAirline() {
        return bookAirline;
    }

    public void setBookAirline(String bookAirline) {
        this.bookAirline = bookAirline;
    }

    public String getFlightNumber() {
        return flightNumber;
    }

    public void setFlightNumber(String flightNumber) {
        this.flightNumber = flightNumber;
    }

    public Date getDepartureTime() {
        return departureTime;
    }

    public void setDepartureTime(Date departureTime) {
        this.departureTime = departureTime;
    }

    public Date getArriveTime() {
        return arriveTime;
    }

    public void setArriveTime(Date arriveTime) {
        this.arriveTime = arriveTime;
    }

    public String getDepartureLocation() {
        return departureLocation;
    }

    public void setDepartureLocation(String departureLocation) {
        this.departureLocation = departureLocation;
    }

    public String getArriveLocation() {
        return arriveLocation;
    }

    public void setArriveLocation(String arriveLocation) {
        this.arriveLocation = arriveLocation;
    }

    public String getReturnFlightNumber() {
        return returnFlightNumber;
    }

    public void setReturnFlightNumber(String returnFlightNumber) {
        this.returnFlightNumber = returnFlightNumber;
    }


    public String getReturnDepartureLocation() {
        return returnDepartureLocation;
    }

    public void setReturnDepartureLocation(String returnDepartureLocation) {
        this.returnDepartureLocation = returnDepartureLocation;
    }

    public String getReturnArriveLocation() {
        return returnArriveLocation;
    }

    public void setReturnArriveLocation(String returnArriveLocation) {
        this.returnArriveLocation = returnArriveLocation;
    }

    public String getFlightTime() {
        return flightTime;
    }

    public void setFlightTime(String flightTime) {
        this.flightTime = flightTime;
    }

    public String getCrossDay() {
        return crossDay;
    }

    public void setCrossDay(String crossDay) {
        this.crossDay = crossDay;
    }

    public String getReturnFlightTime() {
        return returnFlightTime;
    }

    public void setReturnFlightTime(String returnFlightTime) {
        this.returnFlightTime = returnFlightTime;
    }

    public String getReturnCrossDay() {
        return returnCrossDay;
    }

    public void setReturnCrossDay(String returnCrossDay) {
        this.returnCrossDay = returnCrossDay;
    }


    public Date getReturnDepartureTime() {
        return returnDepartureTime;
    }

    public void setReturnDepartureTime(Date returnDepartureTime) {
        this.returnDepartureTime = returnDepartureTime;
    }

    public Date getReturnArriveTime() {
        return returnArriveTime;
    }

    public void setReturnArriveTime(Date returnArriveTime) {
        this.returnArriveTime = returnArriveTime;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public String getReturnPosition() {
        return returnPosition;
    }

    public void setReturnPosition(String returnPosition) {
        this.returnPosition = returnPosition;
    }


}
